﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class CompanyInfos : System.Web.UI.PageEx
{
    private DataSet ds = null;
    private string strSelectCode = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        strSelectCode = Convert.ToString(Request.QueryString["Type"]);
        strSelectCode = string.IsNullOrEmpty(strSelectCode) ? "AboutUs" : strSelectCode;
        if (!Page.IsPostBack)
        {
            DataBinds();
        }
    }
    private void DataBinds()
    {
        Model.DbCompInfo dbCompInfo = DalEx.DbCompInfoEx.GetModel(strSelectCode);
        if (dbCompInfo != null)
        {
            lblSubTitle.Text = lblShowTitle.Text = dbCompInfo.CName;
            litShowInfo.Text = HttpUtility.HtmlDecode(dbCompInfo.CNotes);

            setMeta(dbCompInfo.CName, dbCompInfo.CKeywords, dbCompInfo.CDescription);
        }
    }
    protected void rptType_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {
            DataRowView drv = (DataRowView)e.Item.DataItem;
            HyperLink hlLinks = (HyperLink)e.Item.FindControl("hlLinks");
            string strCurrentName = Convert.ToString(drv["CCode"]);
            if (strCurrentName.Equals(strSelectCode, StringComparison.OrdinalIgnoreCase))
                hlLinks.Attributes.Add("class", "on");
        }
    }
    private void setMeta(string title, string key, string des)
    {
        string strWebTitle = string.Empty, strWebKeywords = string.Empty, strWebDescription = string.Empty;
        Model.DbSystem dbSystem = Dal.DbSystemDal.Select(1);
        if (dbSystem != null)
        {
            strWebTitle = dbSystem.STitle;
            strWebKeywords = dbSystem.SKeywords;
            strWebDescription = dbSystem.SDescription;
        }
        HtmlMeta keywords = new HtmlMeta(); // keywords
        HtmlMeta description = new HtmlMeta(); // description
        keywords.Name = "keywords";
        keywords.Content = string.IsNullOrEmpty(key) ? strWebKeywords : key;

        this.Title = string.IsNullOrEmpty(title) ? strWebTitle : title;

        description.Name = "description";
        description.Content = string.IsNullOrEmpty(des) ? strWebDescription : des;

        Page.Header.Controls.Add(keywords);
        Page.Header.Controls.Add(description);
    }
}
